package com.rpframework.module.common.bottom.listener;

import com.rpframework.module.common.bottom.entity.enums.SourceType;
import com.rpframework.module.common.bottom.enums.FileType;
import com.rpframework.module.common.config.Config;
import org.springframework.web.context.ServletContextAware;

import javax.annotation.Resource;
import javax.servlet.ServletContext;
import java.util.Map;


public class ConfigListener implements ServletContextAware {

    @Resource(name = "config")
    private Config config;

    @Override
    public void setServletContext(ServletContext servletContext) {
        Map<String, String> pair = config.getKeyPair();
        if (pair != null) SourceType.KEY_PAIR.putAll(pair);
        FileType.filePath = config.getUploadFinalDir(servletContext);
    }
}